var o = getApp();

Page({
    data: {
        showTwo: !1,
        shareBox: !1,
        isLoadingEnd: !1
    },
    onLoad: function(t) {
        if (t.id && this.setData({
            id: t.id
        }), t.scene) {
            var e = decodeURIComponent(t.scene);
            if (e) {
                var a = [];
                a = e.split(",");
                for (var n = 0; n < a.length; n++) {
                    var s;
                    "mid" == (s = a[n].split("="))[0] && o._setMid(s[1]), "id" == s[0] && this.setData({
                        id: s[1]
                    });
                }
            }
        }
        this.getData();
    },
    goDetail: function(o) {
        var t = o.currentTarget.dataset.info;
        console.log(t), wx.navigateTo({
            url: "/packageE/groupCode/groupCodeShow/groupCodeShow?id=" + this.data.id + "&label=" + t
        });
    },
    tapShow: function() {
        this.setData({
            showTwo: !0
        });
    },
    CloseBtn: function() {
        this.setData({
            showTwo: !1,
            shareBox: !1
        });
    },
    shareBox: function(t) {
        wx.showLoading({
            title: "加载中"
        });
        var e = this, a = o.getNetAddresss("plugin.group-code.api.group-code.get-share-poster");
        o._postNetWork({
            url: a,
            data: {
                id: this.data.id,
                ingress: "weChatApplet"
            },
            success: function(o) {
                var t = o.data;
                wx.hideLoading({
                    success: function(o) {}
                }), 1 == t.result ? (console.log(t), e.setData({
                    minImga: t.data.image_url,
                    base: t.data.base64Image,
                    shareBox: !0
                })) : (wx.showToast({
                    title: t.msg,
                    icon: "none"
                }), console.log(t.msg));
            }
        });
    },
    saveImg: function() {
        wx.getSetting({
            success: function(o) {
                o.authSetting["scope.writePhotosAlbum"] || wx.authorize({
                    scope: "scope.writePhotosAlbum",
                    success: function() {
                        console.log("授权成功");
                    }
                });
            }
        });
        var o = this.data.minImga;
        wx.downloadFile({
            url: o,
            success: function(o) {
                console.log(o), wx.saveImageToPhotosAlbum({
                    filePath: o.tempFilePath,
                    success: function(o) {
                        wx.showToast({
                            title: "保存成功",
                            icon: "none",
                            duration: 2e3
                        });
                    },
                    fail: function(o) {
                        console.log(o), "saveImageToPhotosAlbum:fail auth deny" === o.errMsg && (console.log("当初用户拒绝，再次发起授权"), 
                        wx.openSetting({
                            success: function(o) {
                                o.authSetting["scope.writePhotosAlbum"] ? wx.showToast({
                                    icon: "none",
                                    title: "获取权限成功,再次长按保存图片",
                                    duration: 1500
                                }) : wx.showToast({
                                    icon: "none",
                                    title: "获取权限失败,保存图片需要用户授权",
                                    duration: 1500
                                });
                            }
                        }));
                    },
                    complete: function(o) {
                        console.log(o);
                    }
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.info.code_name,
            path: "/packageE/groupCode/groupCodeLabel/groupCodeLabel?id=" + this.data.id
        };
    },
    getData: function() {
        var t = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = this, a = o.getNetAddresss("plugin.group-code.api.group-code.get-group-code");
        o._postNetWork({
            url: a,
            data: {
                id: this.data.id
            },
            success: function(a) {
                wx.hideLoading();
                var n = a.data;
                1 == n.result ? (console.log(n), o._isTextEmpty(n.data.data) ? wx.redirectTo({
                    url: "/packageE/groupCode/groupCodeShow/groupCodeShow?id=" + e.data.id
                }) : (wx.setNavigationBarTitle({
                    title: n.data.data.code_name
                }), t.setData({
                    isLoadingEnd: !0,
                    info: n.data.data,
                    shop_log: n.data.shop_log
                }))) : (wx.showToast({
                    title: n.msg,
                    icon: "none"
                }), console.log(n.msg), setTimeout(function() {
                    return wx.navigateBack();
                }, 1e3));
            }
        });
    }
});